<template>
	<!-- 管理员注册 -->
	<div class="t_body_bg" :style="{backgroundImage: 'url('+bgimg+')'}">
    	<div class="t_login_box">
			<div class="t_logo_font" >
				<span v-if="!logoimg">logo</span>
				<img :src="logoimg" alt="">
			</div>
			<div class="t_welcome_font"  >{{ comname }}</div>

			<div class="t_login_con" >

				<div  class="t_input_box">
					<img src="../../static/img/user.png" alt="">
					<el-input v-model="form.domain" placeholder="请输入域名"></el-input>
				</div>

				<div  class="t_input_box">
					<img src="../../static/img/user.png" alt="">
					<el-input v-model="form.platfname" placeholder="请输入系统名称"></el-input>
				</div>

				<div class="t_input_box">
					<img src="../../static/img/user.png" alt="">
					<el-input :readonly="readonly" @focus="readonly=false" v-model="form.username" placeholder="账号名称"></el-input>
				</div>
				<div class="t_input_box">
					<img src="../../static/img/psd.png" alt="">
					<el-input v-model="form.password" placeholder="请输入密码" show-password></el-input>
				</div>

				<div >
					<div class="t_input_box">
						<el-input v-model="form.fname" style="margin-left: 36px;" placeholder="请输入负责人姓名"></el-input>
					</div>
					<div class="t_input_box">
						<el-input v-model="form.phonenum" style="margin-left: 36px;" placeholder="请输入手机号"></el-input>
					</div>
					<div class="t_input_box">
						<el-input v-model="form.code" style="margin-left: 36px;width: 148px;" placeholder="请输入验证码"></el-input>
						<div @click="getcode" class="t_get_code">{{ codemsg }}</div>
					</div>
					<!-- <div class="t_input_box">

						<el-input v-model="form.yqcode" style="margin-left: 36px;" placeholder="请输入邀请码"></el-input>
					</div> -->
					<div @click="loginorreg" class="t_login_btn_box">
						注册
					</div>
				</div>


			</div>
			<!-- 找回密码 -->

		</div>
	</div>
</template>

<script>

	export default {
		name: 'login2',
    components:{

    },
		data() {
			return {

				codemsg:'获取验证码',
				form:{
					username:'',//账号名称
					password:'',//密码
					phonenum:'',//手机号
					code:'',//验证码
					yqcode:'',//邀请码
					passwordagin:'',//再次输入密码
					fname:'',//负责人姓名
					platfname:'',//系统名称
          domain:""
				},
				bgimg:require('@/../static/img/loginbg.png'),
				// bgimg:'https://img.jbzj.com/file_images/article/202205/2022053011053840.png',
				logoimg:'',
				comname:'管理员注册',
				readonly:true
			}
		},
		created() {

		},
		mounted() {

		},
		methods: {

			//注册，登录，找回
			loginorreg(){
				//注册
					if(this.form.username==''){
						this.$message.error('请输入用户名');
						return
					}
					if(this.form.password==''){
						this.$message.error('请输入密码');
						return
					}
					if(this.form.phonenum==''){
						this.$message.error('请输入手机号');
						return
					}
					if(this.form.code==''){
						this.$message.error('请输入验证码');
						return
					}
					if(this.form.fname==''){
						this.$message.error('请输入负责人姓名');
						return
					}
					if(this.form.platfname==''){
						this.$message.error('请输入系统名称');
						return
					}

					var obg={
						name:this.form.username,
						password:this.form.password,
						mobile:this.form.phonenum,
						sms_code:this.form.code,
						platform_name:this.form.platfname,
						head_name:this.form.fname,
            domain:this.form.domain
					}

					axios.post('/own/user/register',obg).then((response)=>{
						if (response.data.msg.code == 0) {
							this.$message({
								message: '注册成功',
								type: 'success'
							});
              window.open('http://' + this.form.domain + '/hou/xitongpeizhi')
						} else {
							this.$message.error(response.data.msg.info);
						}
					})
			},
			//获取验证码
			getcode(){

				// if(this.form.phonenum.length!=11){
				// 	this.$message.error('请输入正确手机号');
				// 	return
				// }
				if(this.codemsg=='获取验证码'){
					this.codemsg = 60
					var time = setInterval(()=>{
						if(this.codemsg>0){
							this.codemsg--
						}else{
							this.codemsg = '获取验证码'
							clearInterval(time)
						}
					},1000)

					axios.post('/api/register/code/send',{
						mobile:this.form.phonenum,
						type:'owner'
					}).then((response)=>{
						if (response.data.msg.code == 0) {
							// this.$message({
							// 	message: '发送成功',
							// 	type: 'success'
							// });
						} else {
							this.$message.error(response.data.msg.info);
						}
					})
				}

			}
		}
	}
</script>

<style scoped>
	.t_body_bg{
		width:100vw;
		height:100vh;
		/* background-image: url('/static/img/loginbg.png'); */
		background-size: 100% 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;

	}
	.t_login_box{
		width: 524px;
		/* height: 776px; */
		padding: 30px;
		border-radius: 45px;
		background-color: #f6f8fb;
		text-align: center;
		margin-right: 200px;
	}
	.t_login_con{
		width: 300px;
		margin-left: auto;
		margin-right: auto;
	}
	.t_type_box{
		display: flex;
		justify-content: center;
		margin-bottom: 30px;
	}
	.t_type_btn{
		width: 100px;
		height: 50px;
		background-color: #e3e8f1;
		border-radius: 25px;
		text-align: center;
		line-height:50px ;
		color: #AFB3BC;
		border: 1px solid #E3E8F1;
		cursor: pointer;
	}
	.t_type_btn_lei{
		background-color: #E6EFFF;
		color: #005AFF;
		border: 1px solid #005AFF;
	}
	.t_input_box{
		border: 1px solid #e3e8f1;
		border-radius: 25px;
		display: flex;
		height: 46px;
		align-items: center;
		background-color: white;
		overflow: hidden;
		margin-bottom: 20px;
	}
	.t_input_box img{
		margin-left: 22px;
		margin-right: 0px;
	}
	/deep/.t_input_box .el-input__inner{
		border: none;
	}
  /deep/ .el-input__inner{
    background: #fff !important;
    border: 1px solid #fff !important;
  }
	.t_get_code{
		width: 112px;
		height: 40px;
		background: #e6efff;
		border: 1px solid #005aff;
		border-radius: 25px;
		text-align: center;
		line-height: 40px;
		color: #005AFF;
		font-size: 14px;
		cursor: pointer;

	}
	.t_login_btn_box{
		background-color:#005aff;
		color: white;
		text-align: center;
		height: 50px;
		line-height: 50px;
		font-size: 18px;
		border-radius: 25px;
		margin-top: 60px;
		cursor: pointer;
	}
	.t_tips_btn{
		color: #afb3bc;
		font-size: 14px;
		text-align: center;
		margin-top: 23px;
		cursor: pointer;
	}
	.t_logo_font{
		margin-top: 58px;
		color: #005aff;
		font-size: 29px;
	}
	.t_logo_font img{
		width: 100px;
		display: block;
		margin-left: auto;
		margin-right: auto;
	}
	.t_welcome_font{
		margin-top: 28px;
		margin-bottom: 28px;
		font-weight: bold;
		font-size: 28px;
	}
</style>
<style scoped lang="less">

</style>
